package com.cloudptt.api.product.func.media.light;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;

import com.cloudptt.api.product.log.Log;

public class BreathingLightReceiver extends BroadcastReceiver {

	
	public final static String THIS_FILE = "BreathingLightReceiver";
	public static final String ALARM_TIMER_ACTION="breathing.alarm.light";
	private Context ctx = null;
	private IBreathingLight light = null;
	
	public BreathingLightReceiver(Context ctx,IBreathingLight light) {
		this.ctx = ctx;
		this.light = light;
		ctx.registerReceiver(this, new IntentFilter(ALARM_TIMER_ACTION));
	}

	@Override
	public void onReceive(Context arg0, Intent intent) {
		String action = intent.getAction();
//		Log.d(THIS_FILE, "onReceive:Action is " + action);
		if(action == null
				|| !ALARM_TIMER_ACTION.equals(action))
		{
			return;
		}	
		
//		light.closeBreathingLight();
		light.openBreathingLight();
	}
	
	public void clearResource() {
//		Log.d(THIS_FILE, "LBSTimerReceiver clearResource");
		this.ctx.unregisterReceiver(this);
		this.ctx = null;
	}

}
